<template>
    <div>
        <el-breadcrumb separator="/" style="margin-bottom: 20px;">
            <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-table :data="rolelist" style="width: 100%" border>
                <el-table-column label="#" width="50" type="index">
                </el-table-column>
                <el-table-column label="权限名称">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.authName }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="路径">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.path }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="权限等级">
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.level == 0">一级</el-tag>
                        <el-tag v-if="scope.row.level == 1" type="success">二级</el-tag>
                        <el-tag v-if="scope.row.level == 2" type="warning">三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>
<script>
export default {
    data() {
        return {
            rolelist: []
        }
    },
    methods: {
        async getRoleList() {
            const { data: { data, meta } } = await this.$http.get('rights/list');
            if (meta.status !== 200) return this.$message.error('获取权限数据失败，请重新获取');
            this.rolelist = data;
        }
    },
    created() {
        this.getRoleList();
    }
}
</script>
<style lang="less" scoped>
.el-card {
    margin-bottom: 60px;
}
.el-table{
    margin-top: 20px;
}
</style>